var express = require('express');
var router = express.Router();

/* GET users listing. */
//引入第二层函数
const {
  getLogin2,
  getCheck2,
  getWantCheck2,
  argreeCheck2,
  getWantChange2,
  getChange2,
  argreeChange2,
  create2
}=require("../service/users.js")


/* GET home page. */
// 用户生成
router.post('/create', async function (req, res, next) {
  // console.log(req.body);
  
  const result = await create2(req.body);
  res.send(result)
});

//获取申请成为卖家的用户
router.post('/shop', async function (req, res, next) {
  // console.log(req.body);
  
  const result = await getWantChange2(req.body);
  res.send(result)
});
//用户登录
router.post('/login', async function (req, res, next) {
  console.log(req.body);
  
  const result = await getLogin2(req.body);
  res.send(result)
});
//用户认证
router.put('/check', async function (req, res, next) {
  // console.log(req.body);
  
  const result = await getCheck2(req.body);
  res.send(result)
});
//获取需要认证的用户
router.post('/getRz', async function (req, res, next) {
  // console.log(req.body);
  
  const result = await getWantCheck2(req.body);
  res.send(result)
});
// 同意认证
router.put('/ok', async function (req, res, next) {
  // console.log(req.body);
  
  const result = await argreeCheck2(req.body);
  res.send(result)
});


//用户审核
router.put('/change', async function (req, res, next) {
  // console.log(req.body);
  
  const result = await getChange2(req.body);
  res.send(result)
});
// 同意审核
router.put('/changeOk', async function (req, res, next) {
  // console.log(req.body);
  
  const result = await argreeChange2(req.body);
  res.send(result)
});
module.exports = router;
